package com.dqyt.khjc.controller;

import com.dqyt.khjc.bean.ResultMsg;
import com.dqyt.khjc.service.LoginHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 登陆历史记录
 */
@RestController
public class LoginHistoryController {

    @Autowired
    private LoginHistoryService loginHistoryService;

    /**
     * 分页查询 登陆历史记录
     * @param request
     * @param page
     * @param size
     * @param userName  用户昵称
     * @param userPhone 用户手机
     * @param userAccount 用户账号
     * @return
     */
    @RequestMapping(value = "/api/getLogHisListPage", method = {RequestMethod.GET,RequestMethod.POST})
    public ResultMsg getLogHisListPage(HttpServletRequest request,
                                         @RequestParam(defaultValue = "1") Integer page,
                                         @RequestParam(defaultValue = "10") Integer size,
                                         @RequestParam(name = "userName", required = false, defaultValue = "") String userName,
                                         @RequestParam(name = "userPhone", required = false, defaultValue = "") String userPhone,
                                         @RequestParam(name = "userAccount", required = false, defaultValue = "") String userAccount
    ){
        ResultMsg resultMsg = loginHistoryService.getLogHisListPage(request,page,size,userName,userPhone,userAccount);
        return resultMsg;
    }

}
